<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>监控系统导航平台</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/font-awesome-local.css') }}">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Arial, sans-serif;
        }
        body {
            background-color: #f5f5f5;
            color: #333;
            overflow: hidden;
            height: 100vh;
            display: flex;
            margin: 0;
            padding: 0;
        }
        /* 主容器 */
        .main-container {
            display: flex;
            height: 100vh;
            position: relative;
        }
        /* 左侧导航栏 */
        .sidebar {
            width: 160px;
            background-color: #f8f9fa;
            color: #333;
            overflow-y: auto;
            min-width: 140px;
            max-width: 180px;
            transition: transform 0.3s ease;
            z-index: 1000;
            border-right: 1px solid #e9ecef;
        }
        .sidebar.collapsed {
            width: 0;
            min-width: 0;
            max-width: 0;
            overflow: hidden;
            border-right: none;
        }
        /* 侧边栏切换按钮 */
        .sidebar-toggle {
            position: fixed;
            left: 160px;
            top: 50%;
            transform: translateY(-50%);
            background-color: #6c757d;
            color: white;
            border: none;
            border-radius: 0 8px 8px 0;
            padding: 15px 8px;
            cursor: pointer;
            z-index: 1001;
            transition: all 0.3s ease;
            box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        }
        .sidebar-toggle:hover {
            background-color: #5a6268;
        }
        body.sidebar-collapsed .sidebar-toggle {
            left: 0px;
        }
        body:not(.sidebar-collapsed) .sidebar-toggle {
            left: 160px;
        }
        .sidebar-header {
            padding: 15px;
            border-bottom: 1px solid #e9ecef;
            background-color: #ffffff;
        }
        .sidebar-header h2 {
            font-size: 1rem;
            font-weight: 600;
            color: #495057;
        }
        .sidebar-menu {
            padding: 10px 0;
        }
        .menu-item {
            display: flex;
            align-items: center;
            padding: 10px 15px;
            cursor: pointer;
            transition: background-color 0.3s;
            border-left: 3px solid transparent;
            font-size: 0.9rem;
        }
        .menu-item:hover {
            background-color: #e9ecef;
        }
        .menu-item.active {
            background-color: #e3f2fd;
            border-left-color: #2196f3;
        }
        .menu-item i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
        }
        
        /* 站点导航样式 */
        .site-group {
            margin-bottom: 5px;
        }
        
        /* 一级标题样式 (南京、镇江) */
        .site-group-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 15px;
            cursor: pointer;
            transition: background-color 0.3s;
            border-left: 3px solid transparent;
            font-weight: 700;
            font-size: 1.0rem;
            color: #2c3e50;
        }
        .site-group-header:hover {
            background-color: #e9ecef;
        }
        .site-group-header.active {
            background-color: #e3f2fd;
            border-left-color: #2196f3;
        }
        .site-group-header i {
            margin-right: 8px;
            width: 16px;
            text-align: center;
            color: #495057;
            font-size: 0.9rem;
        }
        
        /* 一级标题 - 镇江 (直接作为subitem的样式) */
        .site-subitem.level-1 {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            cursor: pointer;
            transition: background-color 0.3s;
            font-size: 1.0rem;
            font-weight: 700;
            color: #2c3e50;
            position: relative;
            border-left: 3px solid transparent;
        }
        .site-subitem.level-1:hover {
            background-color: #e9ecef;
        }
        .site-subitem.level-1 i {
            margin-right: 8px;
            width: 16px;
            text-align: center;
            font-size: 0.9rem;
            color: #495057;
        }
        
        /* 二级标题样式 (雍熙、同方) */
        .site-group-header.level-2 {
            padding: 10px 25px;
            font-weight: 600;
            font-size: 0.95rem;
            color: #495057;
        }
        .site-group-header.level-2 i {
            font-size: 0.85rem;
            color: #6c757d;
        }
        
        .site-subitem.level-2 {
            display: flex;
            align-items: center;
            padding: 10px 25px;
            cursor: pointer;
            transition: background-color 0.3s;
            font-size: 0.95rem;
            font-weight: 600;
            color: #495057;
            position: relative;
        }
        .site-subitem.level-2:hover {
            background-color: #e9ecef;
        }
        .site-subitem.level-2 i {
            margin-right: 6px;
            width: 14px;
            text-align: center;
            font-size: 0.85rem;
            color: #6c757d;
        }
        
        .expand-icon {
            transition: transform 0.3s ease;
            font-size: 0.7rem;
            color: #6c757d;
        }
        .expand-icon.expanded {
            transform: rotate(90deg);
        }
        
        .site-submenu {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
            background-color: #f8f9fa;
        }
        .site-submenu.expanded {
            max-height: 500px;
        }
        
        /* 三级标题样式 (雍熙园、食堂1F、食堂2F等) */
        .site-subitem {
            display: flex;
            align-items: center;
            padding: 8px 35px;
            cursor: pointer;
            transition: background-color 0.3s;
            font-size: 0.85rem;
            font-weight: 400;
            color: #6c757d;
            position: relative;
        }
        .site-subitem:hover {
            background-color: #e9ecef;
        }
        .site-subitem i {
            margin-right: 6px;
            width: 14px;
            text-align: center;
            font-size: 0.75rem;
            color: #6c757d;
        }
        .site-status-indicator {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-left: auto;
            margin-right: 8px;
            transition: all 0.3s ease;
        }
        .site-status-indicator.online {
            background-color: #4CAF50;
            box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
        }
        .site-status-indicator.offline {
            background-color: #f44336;
            box-shadow: 0 0 6px rgba(244, 67, 54, 0.6);
        }
        .site-status-indicator.checking {
            background-color: #ff9800;
            box-shadow: 0 0 6px rgba(255, 152, 0, 0.6);
            animation: pulse 1.5s infinite;
        }
        
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
        /* 主内容区域 */
        .content {
            flex: 1;
            display: flex;
            flex-direction: column;
            background-color: #ecf0f1;
            transition: margin-left 0.3s ease;
            margin-left: 0;
            height: 100vh;
            width: calc(100vw - 160px);
            overflow: hidden;
        }
        body.sidebar-collapsed .content {
            width: 100vw;
            margin-left: 0;
        }
        
        /* 内容头部 */
        .content-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 15px;
            background: white;
            border-bottom: 1px solid #e0e0e0;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
            overflow: hidden;
        }
        
        .content-header.collapsed {
            height: 0;
            padding: 0 15px;
            border-bottom: none;
            box-shadow: none;
        }
        
        .breadcrumb {
            display: flex;
            align-items: center;
            font-size: 1.1rem;
            color: #2c3e50;
        }
        
        .breadcrumb span:first-child {
            font-weight: 600;
        }
        
        .breadcrumb span:not(:first-child)::before {
            content: ' > ';
            margin: 0 8px;
            color: #7f8c8d;
        }
        
        /* 当前URL显示区域 */
        .current-url-display {
            display: flex;
            align-items: center;
            margin-left: 20px;
            padding: 6px 12px;
            background-color: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 4px;
            font-size: 0.9rem;
            color: #495057;
            max-width: 400px;
        }
        
        .current-url-display .url-label {
            font-weight: 600;
            margin-right: 8px;
            color: #6c757d;
        }
        
        .current-url-display .url-text {
            font-family: 'Courier New', monospace;
            color: #007bff;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex: 1;
        }
        
        .current-url-display.hidden {
            display: none;
        }
        
        .content-actions {
            display: flex;
            gap: 10px;
        }
        
        /* 日期时间显示 */
        .datetime-display {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #2c3e50;
            font-size: 0.9rem;
            margin-right: 15px;
        }
        .datetime-display .date {
            font-weight: bold;
            margin-bottom: 2px;
        }
        .datetime-display .time {
            font-family: 'Courier New', monospace;
            color: #7f8c8d;
        }
        
        .btn-refresh, .btn-external, .btn-collapse-header, .btn-home {
            background: #3498db;
            color: white;
            border: none;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
        }
        
        .btn-refresh:hover, .btn-external:hover, .btn-collapse-header:hover, .btn-home:hover {
            background: #2980b9;
            transform: translateY(-1px);
        }
        
        .btn-external {
            background: #27ae60;
        }
        
        .btn-external:hover {
            background: #229954;
        }
        
        .btn-home {
            background: #e67e22;
        }
        
        .btn-home:hover {
            background: #d35400;
        }
        
        /* 内容显示区域 */
        .content-display {
            flex: 1;
            position: relative;
            overflow: hidden;
            height: calc(100vh - 50px); /* 占满除content-header外的所有高度，content-header约50px */
            min-height: calc(100vh - 50px);
            transition: height 0.3s ease;
        }
        
        .content-header.collapsed ~ .content-display {
            height: 100vh; /* header收起时占满全部高度 */
        }
        
        /* 悬浮的展开按钮 */
        .floating-expand-btn {
            position: fixed;
            top: 10px;
            right: 20px;
            background: #3498db;
            color: white;
            border: none;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
            z-index: 1000;
            display: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }
        
        .floating-expand-btn:hover {
            background: #2980b9;
            transform: translateY(-1px);
        }
        
        .content-header.collapsed ~ .floating-expand-btn {
            display: block;
        }
        
        /* 欢迎页面样式 */
        .welcome-content {
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px;
        }
        
        .welcome-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            padding: 40px;
            text-align: center;
            max-width: 800px;
            width: 100%;
        }
        
        .welcome-card i {
            font-size: 4rem;
            color: #3498db;
            margin-bottom: 20px;
        }
        
        .welcome-card h2 {
            color: #2c3e50;
            margin-bottom: 15px;
            font-size: 1.8rem;
        }
        
        .welcome-card p {
            color: #666;
            font-size: 1.1rem;
            line-height: 1.6;
            margin-bottom: 30px;
        }
        
        .feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 30px;
        }
        
        .feature-item {
            padding: 20px;
            background: #f8f9fa;
            border-radius: 8px;
            border-left: 4px solid #3498db;
        }
        
        .feature-item:nth-child(2) {
            border-left-color: #e74c3c;
        }
        
        .feature-item:nth-child(3) {
            border-left-color: #f39c12;
        }
        
        .feature-item i {
            font-size: 1.5rem;
            margin-bottom: 10px;
        }
        
        .feature-item:nth-child(1) i {
            color: #3498db;
        }
        
        .feature-item:nth-child(2) i {
            color: #e74c3c;
        }
        
        .feature-item:nth-child(3) i {
            color: #f39c12;
        }
        
        .feature-item h4 {
            color: #2c3e50;
            margin-bottom: 5px;
        }
        
        .feature-item p {
            color: #666;
            font-size: 0.9rem;
            margin: 0;
        }
        
        /* iframe样式 */
        #content-frame {
            width: 100%;
            height: 100%;
            border: none;
            background: white;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
        
        /* 站点卡片容器 */
        .sites-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
            gap: 30px;
            padding: 20px 0;
        }
        
        /* 站点卡片 */
        .site-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            padding: 25px;
            transition: all 0.3s ease;
            border: 1px solid #e0e0e0;
        }
        
        .site-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.15);
        }
        
        .site-card.disabled {
            opacity: 0.6;
            pointer-events: none;
        }
        
        .site-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid #f0f0f0;
        }
        
        .site-name {
            font-size: 1.4rem;
            font-weight: 600;
            color: #2c3e50;
        }
        
        .site-status {
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }
        
        .site-status.online {
            background-color: #d4edda;
            color: #155724;
        }
        
        .site-status.offline {
            background-color: #f8d7da;
            color: #721c24;
        }
        
        .site-info {
            margin-bottom: 20px;
        }
        
        .site-url {
            color: #666;
            font-size: 0.9rem;
            margin-bottom: 5px;
        }
        
        .site-actions {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px;
        }
        
        .action-btn {
            padding: 12px 16px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: 500;
            text-decoration: none;
            text-align: center;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        
        .action-btn.primary {
            background-color: #3498db;
            color: white;
        }
        
        .action-btn.primary:hover {
            background-color: #2980b9;
        }
        
        .action-btn.secondary {
            background-color: #e74c3c;
            color: white;
        }
        
        .action-btn.secondary:hover {
            background-color: #c0392b;
        }
        
        .action-btn.tertiary {
            background-color: #f39c12;
            color: white;
        }
        
        .action-btn.tertiary:hover {
            background-color: #e67e22;
        }
        
        /* 页面标题 */
        .page-title {
            font-size: 2rem;
            color: #2c3e50;
            margin-bottom: 10px;
            font-weight: 600;
        }
        
        .page-subtitle {
            color: #666;
            font-size: 1.1rem;
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <!-- 主容器 -->
    <div class="main-container">
        <!-- 左侧导航栏 -->
        <div class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <h2>监控导航</h2>
            </div>
            <div class="sidebar-menu">
                <!-- 镇江 (一级标题) -->
                <div class="site-subitem level-1" onclick="openSitePage('镇江', '/')">
                    <i class="fas fa-map-marker-alt"></i>
                    <span>镇江</span>
                    <div class="site-status-indicator online"></div>
                </div>
                
                <!-- 南京 (一级标题) -->
                <div class="site-group">
                    <div class="site-group-header" onclick="toggleSiteGroup('nanjing')">
                        <div>
                            <i class="fas fa-map-marker-alt"></i>
                            <span>南京</span>
                        </div>
                        <i class="fas fa-chevron-right expand-icon" id="nanjing-expand-icon"></i>
                    </div>
                    <div class="site-submenu" id="nanjing-submenu">
                        <!-- 雍熙 (二级标题) -->
                        <div class="site-group">
                            <div class="site-group-header level-2" onclick="toggleSiteGroup('yongxi')">
                                <div>
                                    <i class="fas fa-building"></i>
                                    <span>雍熙</span>
                                </div>
                                <i class="fas fa-chevron-right expand-icon" id="yongxi-expand-icon"></i>
                            </div>
                            <div class="site-submenu" id="yongxi-submenu">
                                <!-- 三级标题 -->
                                <div class="site-subitem" onclick="openSitePage('雍熙园', '/')">
                                    <i class="fas fa-leaf"></i>
                                    <span>雍熙园</span>
                                    <div class="site-status-indicator online"></div>
                                </div>
                                <div class="site-subitem" onclick="openSitePage('食堂1F', '/')">
                                    <i class="fas fa-utensils"></i>
                                    <span>食堂1F</span>
                                    <div class="site-status-indicator online"></div>
                                </div>
                                <div class="site-subitem" onclick="openSitePage('食堂2F', '/')">
                                    <i class="fas fa-utensils"></i>
                                    <span>食堂2F</span>
                                    <div class="site-status-indicator online"></div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 同方 (二级标题) -->
                        <div class="site-subitem level-2" onclick="openSitePage('同方', '/')">
                            <i class="fas fa-building"></i>
                            <span>同方</span>
                            <div class="site-status-indicator online"></div>
                        </div>
                        
                        <!-- 南京汇总数据 (二级标题) -->
                        <div class="site-subitem level-2" onclick="openSitePage('南京汇总数据', '/')">
                            <i class="fas fa-chart-bar"></i>
                            <span>南京汇总数据</span>
                            <div class="site-status-indicator" id="status-南京汇总数据"></div>
                        </div>
                    </div>
                </div>
                
                <!-- 汇总数据 (一级标题) -->
                <div class="site-subitem level-1" onclick="openSitePage('汇总数据', '/')">
                    <i class="fas fa-chart-line"></i>
                    <span>汇总数据</span>
                    <div class="site-status-indicator" id="status-汇总数据"></div>
                </div>
                
                <!-- 系统配置 -->
                <div class="site-subitem" onclick="location.href='/config'" style="border-top: 1px solid rgba(255,255,255,0.1); margin-top: 10px; padding-top: 15px;">
                    <i class="fas fa-cog"></i>
                    <span>系统配置</span>
                </div>
            </div>
        </div>

        <!-- 侧边栏切换按钮 -->
        <button class="sidebar-toggle" id="sidebar-toggle">
            <i class="fas fa-chevron-left"></i>
        </button>

        <!-- 主内容区域 -->
        <div class="content">
            <!-- 导航栏 -->
            <div class="content-header">
                <div style="display: flex; align-items: center; flex: 1;">
                    <div class="breadcrumb">
                        <span id="current-site">监控系统导航平台</span>
                        <span id="current-page"></span>
                    </div>
                    <div class="current-url-display hidden" id="current-url-display">
                        <span class="url-label">当前地址:</span>
                        <span class="url-text" id="current-url-text"></span>
                    </div>
                </div>
                <div class="content-actions">
                    <div class="datetime-display">
                        <div class="date" id="current-date"></div>
                        <div class="time" id="current-time"></div>
                    </div>
                    <button class="btn-refresh" onclick="refreshContent()" title="刷新页面">
                        <i class="fas fa-refresh"></i>
                    </button>
                    <button class="btn-external" onclick="openInNewWindow()" title="在新窗口打开">
                        <i class="fas fa-external-link-alt"></i>
                    </button>
                    <button class="btn-collapse-header" onclick="toggleHeader()" title="收起/展开头部">
                        <i class="fas fa-chevron-up" id="header-toggle-icon"></i>
                    </button>
                    <button class="btn-home" onclick="location.href='/config'" title="系统配置">
                        <i class="fas fa-cog"></i>
                    </button>
                </div>
            </div>
            
            <!-- 悬浮的展开按钮 -->
            <button class="floating-expand-btn" onclick="toggleHeader()" title="展开头部">
                <i class="fas fa-chevron-down"></i>
            </button>
            
            <!-- 内容显示区域 -->
            <div class="content-display">
                <!-- 默认欢迎页面 -->
                <div id="welcome-page" class="welcome-content">
                    <div class="welcome-card">
                        <i class="fas fa-network-wired"></i>
                        <h2>欢迎使用监控系统导航平台</h2>
                        <p>
                            本平台为您提供统一的监控系统访问入口<br>
                            请从左侧导航栏选择对应的监控站点，然后选择要访问的功能页面
                        </p>
                        <div class="feature-grid">
                            <div class="feature-item">
                                <i class="fas fa-video"></i>
                                <h4>监控首页</h4>
                                <p>实时监控画面</p>
                            </div>
                            <div class="feature-item">
                                <i class="fas fa-exclamation-triangle"></i>
                                <h4>报警详情</h4>
                                <p>查看报警信息</p>
                            </div>
                            <div class="feature-item">
                                <i class="fas fa-chart-bar"></i>
                                <h4>数据统计</h4>
                                <p>统计分析数据</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- iframe内容显示区域 -->
                <iframe id="content-frame" style="display: none;"></iframe>
            </div>
        </div>
    </div>

    <script>
        // 系统配置数据
        const sitesConfig = {{ sites |tojson|safe }};
        // 站点名取配置信息
        function getSiteConfig(siteName) {
            return sitesConfig.find(site => site.name === siteName) || { host: 'localhost', port: '5000' };
        }
        
        // 更新时间显示
        function updateDateTime() {
            const now = new Date();
            const year = now.getFullYear();
            const month = String(now.getMonth() + 1).padStart(2, '0');
            const day = String(now.getDate()).padStart(2, '0');
            const hours = String(now.getHours()).padStart(2, '0');
            const minutes = String(now.getMinutes()).padStart(2, '0');
            const seconds = String(now.getSeconds()).padStart(2, '0');
            
            const dateStr = `${year}/${month}/${day}`;
            const timeStr = `${hours}:${minutes}:${seconds}`;
            
            const dateEl = document.getElementById('current-date');
            const timeEl = document.getElementById('current-time');
            
            if (dateEl) dateEl.textContent = dateStr;
            if (timeEl) timeEl.textContent = timeStr;
        }
        
        // 侧边栏切换
        document.getElementById('sidebar-toggle').addEventListener('click', function() {
            const sidebar = document.getElementById('sidebar');
            const body = document.body;
            
            sidebar.classList.toggle('collapsed');
            body.classList.toggle('sidebar-collapsed');
            
            const icon = this.querySelector('i');
            if (sidebar.classList.contains('collapsed')) {
                icon.className = 'fas fa-chevron-right';
            } else {
                icon.className = 'fas fa-chevron-left';
            }
        });
        
        // 切换站点组展开/收起
        function toggleSiteGroup(groupName) {
            const submenu = document.getElementById(groupName + '-submenu');
            const icon = document.getElementById(groupName + '-expand-icon');
            
            if (submenu && icon) {
                submenu.classList.toggle('expanded');
                icon.classList.toggle('expanded');
            }
        }
        
        // 根据站点名称获取显示名称（层级结构）
        function getDisplayName(siteName) {
            switch(siteName) {
                case '雍熙园':
                    return '南京 > 雍熙 > 雍熙园';
                case '食堂1F':
                    return '南京 > 雍熙 > 食堂1F';
                case '食堂2F':
                    return '南京 > 雍熙 > 食堂2F';
                case '同方':
                    return '南京 > 同方';
                default:
                    return siteName;
            }
        }
        
        // 检查站点连接状态
        async function checkSiteStatus(siteName) {
            try {
                const config = getSiteConfig(siteName);
                if (!config.enabled) {
                    return false;
                }
                
                const url = `http://${config.host}:${config.port}`;
                const response = await fetch(url, {
                    method: 'HEAD',
                    mode: 'no-cors',
                    timeout: 5000
                });
                return true;
            } catch (error) {
                return false;
            }
        }
        
        // 更新站点状态指示器
        function updateSiteStatusIndicator(siteName, isOnline) {
            const indicator = document.getElementById(`status-${siteName}`);
            if (indicator) {
                indicator.className = `site-status-indicator ${isOnline ? 'online' : 'offline'}`;
            }
        }
        
        // 打开汇总数据页面
        async function openSummaryPage(siteName) {
            const config = getSiteConfig(siteName);
            
            // 检查是否启用
            if (!config.enabled) {
                alert(`${siteName}站点未启用，请先在系统配置中启用该站点。`);
                return;
            }
            
            // 检查连接状态
            const isOnline = await checkSiteStatus(siteName);
            updateSiteStatusIndicator(siteName, isOnline);
            
            if (!isOnline) {
                alert(`${siteName}站点无法连接，请检查网络或站点配置。`);
                return;
            }
            
            const url = `http://${config.host}:${config.port}`;
            
            // 隐藏欢迎页面，显示iframe
            document.getElementById('welcome-page').style.display = 'none';
            document.getElementById('content-frame').style.display = 'block';
            
            // 更新面包屑导航
            const breadcrumb = document.querySelector('.breadcrumb');
            breadcrumb.innerHTML = `<span>导航平台</span><span>${siteName}</span>`;
            
            // 显示当前URL
            const urlDisplay = document.getElementById('current-url-display');
            const urlText = document.getElementById('current-url-text');
            urlText.textContent = url;
            urlDisplay.classList.remove('hidden');
            
            // 设置iframe源地址
            document.getElementById('content-frame').src = url;
            
            // 显示操作按钮
            document.querySelector('.content-actions').style.display = 'flex';
        }
        
        // 打开站点页面 - 支持两种调用方式：
        // 1. openSitePage(siteName, path) - 从配置中获取host和port（推荐）
        // 2. openSitePage(host, port, path, siteName) - 直接指定所有参数（向后兼容）
        function openSitePage(param1, param2, param3, param4) {
            let host, port, path, siteName, areaName;
            
            if (param3 !== undefined && param4 !== undefined) {
                // 四个参数：host, port, path, siteName（旧方式但更安全）
                host = param1;
                port = param2;
                path = param3;
                siteName = param4;
                areaName = getDisplayName(siteName);
            } else if (param3 !== undefined) {
                // 三个参数：host, port, path（旧方式，不推荐）
                host = param1;
                port = param2;
                path = param3;
                // 尝试通过端口和主机查找站点名称
                const site = sitesConfig.find(site => 
                    site.port === port.toString() && site.host === host
                );
                siteName = site ? site.name : '未知站点';
                areaName = site ? getDisplayName(site.name) : `${host}:${port}`;
            } else {
                // 两个参数：siteName, path（新方式，推荐）
                siteName = param1;
                path = param2;
                const config = getSiteConfig(siteName);
                host = config.host;
                port = config.port;
                areaName = getDisplayName(siteName);
            }
            
            const url = `http://${host}:${port}${path}`;
            
            // 隐藏欢迎页面，显示iframe
            document.getElementById('welcome-page').style.display = 'none';
            document.getElementById('content-frame').style.display = 'block';
            
            // 更新面包屑导航
            const breadcrumb = document.querySelector('.breadcrumb');
            breadcrumb.innerHTML = `<span>导航平台</span><span>${areaName}</span>`;
            
            // 显示当前URL
            const urlDisplay = document.getElementById('current-url-display');
            const urlText = document.getElementById('current-url-text');
            urlText.textContent = url;
            urlDisplay.classList.remove('hidden');
            
            // 设置iframe源地址
            document.getElementById('content-frame').src = url;
            
            // 显示操作按钮
            document.querySelector('.content-actions').style.display = 'flex';
        }
        
        // 刷新当前页面
        function refreshContent() {
            const iframe = document.getElementById('content-frame');
            if (iframe.src) {
                iframe.src = iframe.src;
            }
        }
        
        // 在新标签页打开
        function openInNewTab() {
            const iframe = document.getElementById('content-frame');
            if (iframe.src) {
                window.open(iframe.src, '_blank');
            }
        }
        
        // 切换头部显示/隐藏
        function toggleHeader() {
            const header = document.querySelector('.content-header');
            const icon = document.getElementById('header-toggle-icon');
            
            header.classList.toggle('collapsed');
            
            // 切换图标方向
            if (header.classList.contains('collapsed')) {
                icon.className = 'fas fa-chevron-down';
            } else {
                icon.className = 'fas fa-chevron-up';
            }
        }
        
        // 返回首页
        function showWelcomePage() {
            document.getElementById('welcome-page').style.display = 'block';
            document.getElementById('content-frame').style.display = 'none';
            
            // 重置面包屑导航
            const breadcrumb = document.querySelector('.breadcrumb');
            breadcrumb.innerHTML = '<span>监控系统导航平台</span>';
            
            // 隐藏当前URL显示
            const urlDisplay = document.getElementById('current-url-display');
            urlDisplay.classList.add('hidden');
            
            // 隐藏操作按钮
            document.querySelector('.content-actions').style.display = 'none';
        }
        
        // 初始化所有站点状态
        async function initializeSiteStatus() {
            const summarySites = ['汇总数据', '南京汇总数据'];
            
            for (const siteName of summarySites) {
                const config = getSiteConfig(siteName);
                const indicator = document.getElementById(`status-${siteName}`);
                
                if (indicator) {
                    if (!config.enabled) {
                        indicator.className = 'site-status-indicator offline';
                    } else {
                        // 显示检查中状态
                        indicator.className = 'site-status-indicator checking';
                        
                        // 异步检查连接状态
                        const isOnline = await checkSiteStatus(siteName);
                        updateSiteStatusIndicator(siteName, isOnline);
                    }
                }
            }
        }
        
        // 初始化时间显示
        updateDateTime();
        setInterval(updateDateTime, 1000);
        
        // 初始化页面状态
        document.querySelector('.content-actions').style.display = 'none';
        document.getElementById('content-frame').style.display = 'none';
        
        // 页面加载完成后初始化站点状态
        document.addEventListener('DOMContentLoaded', function() {
            initializeSiteStatus();
        });
        
        // 如果页面已经加载完成，立即初始化
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', initializeSiteStatus);
        } else {
            initializeSiteStatus();
        }
    </script>
</body>
</html>